﻿Public Interface IStickyComponent

    Sub OnAttach(ByVal sender As Object, ByVal e As EventArgs)

    Sub OnDetach(ByVal sender As Object, ByVal e As EventArgs)

    ReadOnly Property Mode() As AttachMode

End Interface

Public Interface INamedStickyComponent
    Inherits IStickyComponent

    ReadOnly Property Name() As String

End Interface

Public Enum AttachMode As Integer
    Immediate = 0
    OnInitialized = 1
    OnLoaded = 2
End Enum

'Public Class StickyComponentManager
'    Inherits DependencyObject

'    Public Shared ReadOnly DetachEventArgs As System.EventArgs = New System.EventArgs

'    Private Shared ReadOnly StickyEventManagerProperty As DependencyProperty = DependencyProperty.RegisterAttached("StickyEventManager", GetType(IStickyComponent), GetType(StickyComponentManager), New PropertyMetadata(AddressOf OnStickyComponentChanged))
'    Private Shared Function GetStickyEventManager(ByVal d As DependencyObject) As IStickyComponent
'        Dim result As StickyEventCollection = d.GetValue(StickyEventManagerProperty)
'        If result Is Nothing Then
'            result = New StickyEventCollection
'            d.SetValue(StickyEventManagerProperty, result)
'        End If
'        Return result
'    End Function
'    Private Shared Sub SetStickyEventManager(ByVal d As DependencyObject, ByVal value As IStickyComponent)
'        d.SetValue(StickyEventManagerProperty, value)
'    End Sub


'    Public Shared Sub OnStickyComponentChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
'        Dim c As IStickyComponent
'        If e.OldValue IsNot e.NewValue Then
'            c = TryCast(e.OldValue, IStickyComponent)
'            If c IsNot Nothing Then
'                StickyComponentManager.Detach(d, c)
'            End If
'            c = TryCast(e.NewValue, IStickyComponent)
'            If c IsNot Nothing Then
'                StickyComponentManager.Attach(d, c)
'            End If
'        End If
'    End Sub

'    Public Shared Sub Attach(ByVal d As DependencyObject, ByVal c As IStickyComponent)
'        Select Case c.Mode
'            Case AttachMode.Immediate
'                AttachCore(d, c)
'            Case AttachMode.OnInitialized
'                If GetIsInitialized(d) Then
'                    AttachCore(d, c)
'                Else
'                    Dim a As StickyComponentAttacher = New StickyComponentAttacher(c)
'                    AttachInitialized(d, AddressOf a.AttachOnInitialized)
'                End If
'            Case AttachMode.OnLoaded
'                If GetIsLoaded(d) Then
'                    AttachCore(d, c)
'                Else
'                    Dim a As StickyComponentAttacher = New StickyComponentAttacher(c)
'                    AttachEvent(d, FrameworkElement.LoadedEvent, AddressOf a.AttachOnLoaded)
'                End If
'        End Select
'    End Sub

'    Private Shared Sub AttachCore(ByVal d As DependencyObject, ByVal c As IStickyComponent)
'        c.OnAttach(d, System.EventArgs.Empty)
'        AttachEvent(d, FrameworkElement.UnloadedEvent, AddressOf c.OnDetach)
'    End Sub

'    Public Shared Sub Detach(ByVal d As DependencyObject, ByVal c As IStickyComponent)
'        c.OnDetach(d, DetachEventArgs)
'        DetachEvent(d, FrameworkElement.UnloadedEvent, AddressOf c.OnDetach)
'    End Sub

'    Public Shared Function GetIsInitialized(ByVal d As DependencyObject) As Boolean
'        If TypeOf d Is FrameworkElement Then
'            Return DirectCast(d, FrameworkElement).IsInitialized
'        ElseIf TypeOf d Is FrameworkContentElement Then
'            Return DirectCast(d, FrameworkContentElement).IsInitialized
'        End If
'        Return True
'    End Function

'    Public Shared Function GetIsLoaded(ByVal d As DependencyObject) As Boolean
'        If TypeOf d Is FrameworkElement Then
'            Return DirectCast(d, FrameworkElement).IsLoaded
'        ElseIf TypeOf d Is FrameworkContentElement Then
'            Return DirectCast(d, FrameworkContentElement).IsLoaded
'        End If
'        Return True
'    End Function

'    Public Shared Function GetCommandBindings(ByVal d As DependencyObject) As CommandBindingCollection
'        Dim collection As CommandBindingCollection = Nothing
'        If TypeOf d Is FrameworkElement Then
'            collection = DirectCast(d, FrameworkElement).CommandBindings
'        Else
'            collection = DirectCast(d, FrameworkContentElement).CommandBindings
'        End If
'        Return collection
'    End Function

'    Public Shared Function GetInputBindings(ByVal d As DependencyObject) As InputBindingCollection
'        Dim collection As InputBindingCollection = Nothing
'        If TypeOf d Is FrameworkElement Then
'            collection = DirectCast(d, FrameworkElement).InputBindings
'        Else
'            collection = DirectCast(d, FrameworkContentElement).InputBindings
'        End If
'        Return collection
'    End Function

'    Public Shared Function GetDataContext(ByVal d As DependencyObject) As Object
'        Dim result As Object = d.GetValue(FrameworkElement.DataContextProperty)
'        Return result
'    End Function

'    Public Shared Sub AttachDataContextChanged(ByVal d As DependencyObject, ByVal handler As DependencyPropertyChangedEventHandler)
'        If TypeOf d Is FrameworkElement Then
'            AddHandler DirectCast(d, FrameworkElement).DataContextChanged, handler
'        ElseIf TypeOf d Is FrameworkContentElement Then
'            AddHandler DirectCast(d, FrameworkContentElement).DataContextChanged, handler
'        End If
'    End Sub

'    Public Shared Sub DetachDataContextChanged(ByVal d As DependencyObject, ByVal handler As DependencyPropertyChangedEventHandler)
'        If TypeOf d Is FrameworkElement Then
'            RemoveHandler DirectCast(d, FrameworkElement).DataContextChanged, handler
'        ElseIf TypeOf d Is FrameworkContentElement Then
'            RemoveHandler DirectCast(d, FrameworkContentElement).DataContextChanged, handler
'        End If
'    End Sub

'    Public Shared Sub AttachEvent(ByVal d As DependencyObject, ByVal routedEvent As RoutedEvent, ByVal handler As RoutedEventHandler)
'        If TypeOf d Is FrameworkElement Then
'            DirectCast(d, FrameworkElement).AddHandler(routedEvent, handler)
'        ElseIf TypeOf d Is FrameworkContentElement Then
'            DirectCast(d, FrameworkContentElement).AddHandler(routedEvent, handler)
'        End If
'    End Sub

'    Public Shared Sub DetachEvent(ByVal d As DependencyObject, ByVal routedEvent As RoutedEvent, ByVal handler As RoutedEventHandler)
'        If TypeOf d Is FrameworkElement Then
'            DirectCast(d, FrameworkElement).RemoveHandler(routedEvent, handler)
'        ElseIf TypeOf d Is FrameworkContentElement Then
'            DirectCast(d, FrameworkContentElement).RemoveHandler(routedEvent, handler)
'        End If
'    End Sub

'    Public Shared Sub DetachInitialized(ByVal d As DependencyObject, ByVal handler As EventHandler)
'        If TypeOf d Is FrameworkElement Then
'            RemoveHandler DirectCast(d, FrameworkElement).Initialized, handler
'        Else
'            RemoveHandler DirectCast(d, FrameworkContentElement).Initialized, handler
'        End If
'    End Sub

'    Public Shared Sub AttachInitialized(ByVal d As DependencyObject, ByVal handler As EventHandler)
'        If TypeOf d Is FrameworkElement Then
'            AddHandler DirectCast(d, FrameworkElement).Initialized, handler
'        Else
'            AddHandler DirectCast(d, FrameworkContentElement).Initialized, handler
'        End If
'    End Sub

'    Public Shared Sub Attach(ByVal d As DependencyObject, ByVal binding As CommandBinding)
'        If TypeOf d Is FrameworkElement Then
'            DirectCast(d, FrameworkElement).CommandBindings.Add(binding)
'        Else
'            DirectCast(d, FrameworkContentElement).CommandBindings.Add(binding)
'        End If
'    End Sub

'    Public Shared Sub Detach(ByVal d As DependencyObject, ByVal binding As CommandBinding)
'        If TypeOf d Is FrameworkElement Then
'            DirectCast(d, FrameworkElement).CommandBindings.Remove(binding)
'        Else
'            DirectCast(d, FrameworkContentElement).CommandBindings.Remove(binding)
'        End If
'    End Sub


'    Public Shared Sub Attach(ByVal d As DependencyObject, ByVal binding As InputBinding)
'        If TypeOf d Is FrameworkElement Then
'            DirectCast(d, FrameworkElement).InputBindings.Add(binding)
'        Else
'            DirectCast(d, FrameworkContentElement).InputBindings.Add(binding)
'        End If
'    End Sub

'    Public Shared Sub Detach(ByVal d As DependencyObject, ByVal binding As InputBinding)
'        If TypeOf d Is FrameworkElement Then
'            DirectCast(d, FrameworkElement).InputBindings.Remove(binding)
'        Else
'            DirectCast(d, FrameworkContentElement).InputBindings.Remove(binding)
'        End If
'    End Sub

'    Public Shared Sub Detach(ByVal d As DependencyObject, ByVal command As RoutedCommand)
'        Dim collection As CommandBindingCollection = GetCommandBindings(d)
'        If collection IsNot Nothing Then
'            Dim b As CommandBinding = Nothing
'            For Each binding As CommandBinding In collection
'                If binding.Command Is command Then
'                    b = binding
'                    Exit For
'                End If
'            Next
'            If b IsNot Nothing Then
'                collection.Remove(b)
'            End If
'        End If
'    End Sub

'    Public Shared Sub Attach(ByVal d As DependencyObject, ByVal command As RoutedCommand, ByVal executedHandler As ExecutedRoutedEventHandler, ByVal canExecuteHandler As CanExecuteRoutedEventHandler, Optional ByVal preview As Boolean = False)
'        If command IsNot Nothing And executedHandler IsNot Nothing Then
'            Dim b As CommandBinding = New CommandBinding(command)
'            If preview Then
'                AddHandler b.PreviewExecuted, executedHandler
'                If canExecuteHandler IsNot Nothing Then
'                    AddHandler b.PreviewCanExecute, canExecuteHandler
'                End If
'            Else
'                AddHandler b.Executed, executedHandler
'                If canExecuteHandler IsNot Nothing Then
'                    AddHandler b.CanExecute, canExecuteHandler
'                End If
'            End If
'            GetCommandBindings(d).Add(b)
'        End If
'    End Sub

'    Public Shared Sub Attach(ByVal d As DependencyObject, ByVal gesture As InputGesture, ByVal command As ICommand)
'        Attach(d, New InputBinding(command, gesture))
'    End Sub
'    Public Shared Sub Detach(ByVal d As DependencyObject, ByVal gesture As InputGesture)
'        Dim collection As InputBindingCollection = GetInputBindings(d)
'        If collection IsNot Nothing Then
'            Dim b As InputBinding = Nothing
'            For Each binding As InputBinding In collection
'                If binding.Gesture.Equals(gesture) Then
'                    b = binding
'                    Exit For
'                End If
'            Next
'            If b IsNot Nothing Then
'                collection.Remove(b)
'            End If
'        End If
'    End Sub

'    Public Shared Sub Attach(ByVal d As DependencyObject, ByVal stickyEvent As RoutedEvent, ByVal handler As RoutedEventHandler)
'        Dim eventManager As StickyEventCollection = GetStickyEventManager(d)
'        Dim a As StickyEventAttacher = New StickyEventAttacher(stickyEvent, handler, False, Nothing)
'        eventManager.Add(a)
'    End Sub
'    Public Shared Sub Attach(ByVal d As DependencyObject, ByVal stickyEvent As RoutedEvent, ByVal handler As RoutedEventHandler, ByVal isOneShot As Boolean)
'        Dim eventManager As StickyEventCollection = GetStickyEventManager(d)
'        Dim a As StickyEventAttacher = New StickyEventAttacher(stickyEvent, handler, isOneShot, Nothing)
'        eventManager.Add(a)
'    End Sub
'    Public Shared Sub Attach(ByVal d As DependencyObject, ByVal stickyEvent As RoutedEvent, ByVal handler As RoutedEventHandler, ByVal ParamArray cancelEvents() As RoutedEvent)
'        Dim eventManager As StickyEventCollection = GetStickyEventManager(d)
'        Dim a As StickyEventAttacher = New StickyEventAttacher(stickyEvent, handler, True, cancelEvents)
'        eventManager.Add(a)
'    End Sub

'    Public Shared Sub Detach(ByVal d As DependencyObject, ByVal stickyEvent As RoutedEvent, ByVal handler As RoutedEventHandler)
'        Dim eventManager As StickyEventCollection = GetStickyEventManager(d)
'        Dim mykey As StickyEventKey = New StickyEventKey With {.StickyEvent = stickyEvent, .EventHandler = handler}
'        If eventManager.Contains(mykey) Then
'            eventManager.Remove(mykey)
'        End If
'    End Sub

'    Private Class StickyComponentAttacher
'        Private _Component As IStickyComponent
'        Public Sub New(ByVal c As IStickyComponent)
'            MyBase.New()
'            _Component = c
'        End Sub

'        Public Sub AttachOnInitialized(ByVal sender As Object, ByVal e As EventArgs)
'            _Component.OnAttach(sender, e)
'            AttachEvent(sender, FrameworkElement.UnloadedEvent, AddressOf _Component.OnDetach)
'            AttachInitialized(sender, AddressOf AttachOnInitialized)
'        End Sub

'        Public Sub AttachOnLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
'            _Component.OnAttach(sender, e)
'            AttachEvent(sender, FrameworkElement.UnloadedEvent, AddressOf _Component.OnDetach)
'            DetachEvent(sender, FrameworkElement.LoadedEvent, AddressOf AttachOnLoaded)
'        End Sub
'    End Class

'    Private Class StickyEventAttacher
'        Implements IStickyComponent

'        Private _EventHandler As RoutedEventHandler
'        Private _CancelEvents() As RoutedEvent
'        Private _Event As RoutedEvent
'        Private _IsOneShot As Boolean

'        Public Sub New(ByVal stickyEvent As RoutedEvent, ByVal handler As RoutedEventHandler, ByVal isOneShot As Boolean, ByVal cancelEvents() As RoutedEvent)
'            MyBase.New()
'            _EventHandler = handler
'            _Event = stickyEvent
'            _CancelEvents = cancelEvents
'            _IsOneShot = isOneShot Or (cancelEvents IsNot Nothing AndAlso cancelEvents.Length > 0)
'        End Sub

'        Public ReadOnly Property StickyEvent() As RoutedEvent
'            Get
'                Return _Event
'            End Get
'        End Property

'        Public ReadOnly Property EventHandler() As RoutedEventHandler
'            Get
'                Return _EventHandler
'            End Get
'        End Property

'        Public ReadOnly Property Mode() As AttachMode Implements IStickyComponent.Mode
'            Get
'                Return AttachMode.Immediate
'            End Get
'        End Property

'        Public Sub OnAttach(ByVal sender As Object, ByVal e As System.EventArgs) Implements IStickyComponent.OnAttach
'            If _IsOneShot Then
'                AttachEvent(sender, _Event, AddressOf OnOneShotEvent)
'                If _CancelEvents IsNot Nothing Then
'                    For Each ev As RoutedEvent In _CancelEvents
'                        AttachEvent(sender, ev, AddressOf OnFailEvent)
'                    Next
'                End If
'            Else
'                AttachEvent(sender, _Event, _EventHandler)
'            End If
'        End Sub

'        Public Sub OnDetach(ByVal sender As Object, ByVal e As System.EventArgs) Implements IStickyComponent.OnDetach
'            If _IsOneShot Then
'                DetachEvent(sender, _Event, AddressOf OnOneShotEvent)
'                If _CancelEvents IsNot Nothing Then
'                    For Each ev As RoutedEvent In _CancelEvents
'                        DetachEvent(sender, ev, AddressOf OnFailEvent)
'                    Next
'                End If
'            Else
'                DetachEvent(sender, _Event, _EventHandler)
'            End If
'        End Sub

'        Public Sub OnOneShotEvent(ByVal sender As Object, ByVal e As RoutedEventArgs)
'            _EventHandler(sender, e)
'            Detach(sender, _Event, _EventHandler)
'        End Sub

'        Public Sub OnFailEvent(ByVal sender As Object, ByVal e As EventArgs)
'            Detach(sender, _Event, _EventHandler)
'        End Sub
'    End Class

'    Private Structure StickyEventKey
'        Implements IEquatable(Of StickyEventKey)

'        Public StickyEvent As RoutedEvent
'        Public EventHandler As RoutedEventHandler
'        Public Overrides Function Equals(ByVal obj As Object) As Boolean
'            Dim other As StickyEventKey = CType(obj, StickyEventKey)
'            Return (StickyEvent Is other.StickyEvent And EventHandler = other.EventHandler)
'        End Function

'        Public Function Equals1(ByVal other As StickyEventKey) As Boolean Implements System.IEquatable(Of StickyEventKey).Equals
'            Return Me.Equals(other)
'        End Function
'    End Structure

'    Private Class StickyEventCollection
'        Inherits StickyUtilityCollection(Of StickyEventKey, StickyEventAttacher)

'        Protected Overrides Function GetKeyForItem(ByVal item As StickyEventAttacher) As StickyEventKey
'            Return New StickyEventKey With {.StickyEvent = item.StickyEvent, .EventHandler = item.EventHandler}
'        End Function
'    End Class
'End Class

'Public Class StickyComponentCollection(Of T As IStickyComponent)
'    Inherits System.Collections.ObjectModel.ObservableCollection(Of T)
'    Implements IStickyComponent, IList

'    Private _AttachedTo As DependencyObject
'    Private _Dictionary As New Dictionary(Of String, T)

'    Public Sub New()
'        MyBase.New()
'    End Sub
'    Public Sub New(ByVal list As System.Collections.Generic.List(Of T))
'        MyBase.New(list)
'    End Sub
'    Public Sub New(ByVal collection As System.Collections.Generic.IEnumerable(Of T))
'        MyBase.New(collection)
'    End Sub

'    Protected Overrides Sub ClearItems()
'        For Each c As IStickyComponent In Me
'            StickyComponentManager.Detach(_AttachedTo, c)
'        Next
'        _Dictionary.Clear()
'        MyBase.ClearItems()
'    End Sub

'    Public Shared Function GetKeyForItem(ByVal item As T) As String
'        Dim result As String = Nothing
'        If GetType(INamedStickyComponent).IsAssignableFrom(GetType(T)) Then
'            result = DirectCast(item, INamedStickyComponent).Name
'        End If
'        Return result
'    End Function

'    Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As T)
'        If _AttachedTo IsNot Nothing Then
'            StickyComponentManager.Attach(_AttachedTo, item)
'        End If
'        MyBase.InsertItem(index, item)
'        Dim key As String = GetKeyForItem(item)
'        If key IsNot Nothing Then
'            _Dictionary.Add(key, item)
'        End If
'    End Sub

'    Protected Overrides Sub RemoveItem(ByVal index As Integer)
'        Dim c As IStickyComponent = Me.Item(index)
'        If _AttachedTo IsNot Nothing Then
'            StickyComponentManager.Detach(_AttachedTo, c)
'        End If
'        Dim key As String = GetKeyForItem(c)
'        If key IsNot Nothing Then
'            _Dictionary.Remove(key)
'        End If
'        MyBase.RemoveItem(index)
'    End Sub

'    Protected Overrides Sub SetItem(ByVal index As Integer, ByVal item As T)
'        Dim old As IStickyComponent = Me.Item(index)
'        If _AttachedTo IsNot Nothing Then
'            StickyComponentManager.Detach(_AttachedTo, old)
'            StickyComponentManager.Attach(_AttachedTo, item)
'        End If
'        MyBase.SetItem(index, item)

'        Dim key As String = GetKeyForItem(old)
'        If key IsNot Nothing Then
'            _Dictionary.Remove(key)
'        End If
'        key = GetKeyForItem(item)
'        If key IsNot Nothing Then
'            _Dictionary.Add(key, item)
'        End If
'    End Sub

'    Public ReadOnly Property Mode() As AttachMode Implements IStickyComponent.Mode
'        Get
'            Return AttachMode.Immediate
'        End Get
'    End Property

'    Public Sub OnAttach(ByVal sender As Object, ByVal e As System.EventArgs) Implements IStickyComponent.OnAttach
'        _AttachedTo = TryCast(sender, DependencyObject)
'        If _AttachedTo IsNot Nothing Then
'            For Each c As IStickyComponent In Me
'                StickyComponentManager.Attach(sender, c)
'            Next
'        End If
'    End Sub

'    Public Sub OnDetach(ByVal sender As Object, ByVal e As System.EventArgs) Implements IStickyComponent.OnDetach
'        If _AttachedTo IsNot Nothing Then
'            If (Not (TypeOf e Is RoutedEventArgs)) OrElse DirectCast(e, RoutedEventArgs).RoutedEvent IsNot FrameworkElement.UnloadedEvent Then
'                For Each c As IStickyComponent In Me
'                    StickyComponentManager.Detach(sender, c)
'                Next
'            End If
'            _AttachedTo = Nothing
'        End If
'    End Sub

'    Private Property ListItem(ByVal index As Integer) As Object Implements IList.Item
'        Get
'            Return Item(index)
'        End Get
'        Set(ByVal value As Object)
'            Item(index) = value
'        End Set
'    End Property

'    Default Public Overloads Property Item(ByVal key As String) As T
'        Get
'            Return _Dictionary.Item(key)
'        End Get
'        Set(ByVal value As T)
'            Dim item As T = _Dictionary.Item(key)
'            Dim index As Integer = IndexOf(item)
'            If index >= 0 Then
'                Me.Item(index) = value
'            End If
'        End Set
'    End Property
'End Class

'Public MustInherit Class StickyUtilityCollection(Of TKey, TValue)
'    Inherits System.Collections.ObjectModel.KeyedCollection(Of TKey, TValue)
'    Implements IStickyComponent


'    Private _AttachedTo As DependencyObject

'    Public ReadOnly Property Mode() As AttachMode Implements IStickyComponent.Mode
'        Get
'            Return AttachMode.Immediate
'        End Get
'    End Property

'    Public Sub OnAttach(ByVal sender As Object, ByVal e As System.EventArgs) Implements IStickyComponent.OnAttach
'        If _AttachedTo Is Nothing Then
'            _AttachedTo = sender
'            For Each b As TValue In Me
'                StickyComponentManager.Attach(sender, b)
'            Next
'        End If
'    End Sub

'    Public Sub OnDetach(ByVal sender As Object, ByVal e As System.EventArgs) Implements IStickyComponent.OnDetach
'        If _AttachedTo Is sender Then
'            For Each b As TValue In Me
'                StickyComponentManager.Detach(sender, b)
'            Next
'            _AttachedTo = Nothing
'        End If
'    End Sub

'    Protected Overrides Sub ClearItems()
'        If _AttachedTo IsNot Nothing Then
'            For Each b As TValue In Me
'                StickyComponentManager.Detach(_AttachedTo, b)
'            Next
'        End If
'        MyBase.ClearItems()
'    End Sub

'    Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As TValue)
'        If _AttachedTo IsNot Nothing Then
'            StickyComponentManager.Attach(_AttachedTo, item)
'        End If
'        MyBase.InsertItem(index, item)
'    End Sub

'    Protected Overrides Sub RemoveItem(ByVal index As Integer)
'        If _AttachedTo IsNot Nothing Then
'            Dim item As TValue = Me.Item(index)
'            StickyComponentManager.Detach(_AttachedTo, item)
'        End If
'        MyBase.RemoveItem(index)
'    End Sub

'    Protected Overrides Sub SetItem(ByVal index As Integer, ByVal item As TValue)
'        If _AttachedTo IsNot Nothing Then
'            Dim oldItem As TValue = Me.Item(index)
'            StickyComponentManager.Detach(_AttachedTo, oldItem)
'            StickyComponentManager.Attach(_AttachedTo, item)
'        End If
'        MyBase.SetItem(index, item)
'    End Sub
'End Class

'Public Class StickyCommandBindingCollection
'    Inherits StickyUtilityCollection(Of RoutedCommand, CommandBinding)

'    Protected Overrides Function GetKeyForItem(ByVal item As System.Windows.Input.CommandBinding) As System.Windows.Input.RoutedCommand
'        Return item.Command
'    End Function
'End Class

'Public Class StickyInputBindingCollection
'    Inherits StickyUtilityCollection(Of InputGesture, InputBinding)

'    Protected Overrides Function GetKeyForItem(ByVal item As System.Windows.Input.InputBinding) As System.Windows.Input.InputGesture
'        Return item.Gesture
'    End Function
'End Class